package com.example.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result< T> {
    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> ok(T data) {
        return Result.<T>builder().code(200).message("ok").data(data).build();
    }
    public static <T> Result<T> error(Integer code, String message, T data) {
        return Result.<T>builder().code(code).message(message).data(data).build();
    }

    public static <T> Result<T> error(String message) {
        return Result.<T>builder().code(500).message(message).data( null).build();
    }

}
